#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QKeyEvent>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    this->grabKeyboard();
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_pushButton_clicked()
{
    qDebug("0000");
}

void MainWindow::keyPressEvent(QKeyEvent *event)
{
    static int s_count = 0;
    s_count ++;

    qDebug("%d. key:%d", s_count, event->key());

    if (event->key() == Qt::Key_0)
    {
        qDebug("hit");

        QKeyEvent* event2 = new QKeyEvent(event->type(), Qt::Key_Tab, event->modifiers());
        QApplication::sendEvent(this, event2);
    }
    QMainWindow::keyPressEvent(event);
}

